<%--
  Created by IntelliJ IDEA.
  User: 17826
  Date: 2020/12/19
  Time: 18:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <script src="${pageContext.request.contextPath}/js/jquery-3.5.1.js"></script>
    <button id="btn1">ajax异步提交</button>

    <script>
        $("#btn1").click(function () {
            let url = "${pageContext.request.contextPath}/user/ajaxRequest";
            let data =  '[{"id":1,"username":"zhangsan"},{"id":2,"username":"李四"}]';
            $.ajax({
                type:'post',
                url:url,
                data:data,
                contentType:'application/json;charset=utf-8',
                success:function (resp) {
                    console.log(resp);
                }
            })
        })
    </script>

</body>
</html>
